const path = require("path");
module.exports = {
  devServer: {
    open: true, //浏览器自动打开页面
    /**
     * vue-cli3跨域的全配置！
     */
    proxy: {
      /**
       * (推荐这种方式)
       * 这里是域名后面需要访问的部分(最原始的跨域方式！),！
       * 跨域域名https://baike.baidu.com/后面的访问目录！
       * 在axios路径中写入/article目录下要访问的具体内容路径即可，如果：/article/d4666d640e2e478d283d8c7f.htm即可
       *
       */
      api: {
        //你要跨域的域名(包含host、端口号,切记：一定要带上http头);
        //同一个域名只能设置一次跨域，否则重复报错！
        // target: "http://192.168.0.193/firm.php",
        target: "http://192.168.0.183:8086",
        // target: "https://test.hrycf.com",
        changeOrigin: true, //是否跨域，设置为true;(必须)
        pathRewrite: {
          "^/api": "" //需要rewrite的,
        }
      }
    }
  },

  chainWebpack: config => {
    const types = ["vue-modules", "vue", "normal-modules", "normal"];
    types.forEach(type =>
      addStyleResource(config.module.rule("less").oneOf(type))
    );
    // 移除 prefetch 插件
    // 占用太多带宽
    config.plugins.delete("prefetch");
  },

  css: {
    loaderOptions: {
      less: {
        modifyVars: {
          "primary-color": "#fd7400",
          "link-color": "#fd7400",
          "border-radius-base": "2px",
          "font-size-base": "1rem"
        },
        javascriptEnabled: true
      }
    }
  },
  publicPath: "./",
  outputDir: "company",
  assetsDir: undefined,
  runtimeCompiler: undefined,
  productionSourceMap: undefined,
  parallel: undefined
};
function addStyleResource(rule) {
  rule
    .use("style-resource")
    .loader("style-resources-loader")
    .options({
      patterns: [
        path.resolve(__dirname, "./src/styles/common.less"),
        path.resolve(__dirname, "./src/styles/theam.less"),
        path.resolve(__dirname, "./src/styles/mixins.less")
      ]
    });
}
